<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">
    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
        </script>
        <style type="text/css">
            .c_c {
                background: gray;
            }
            .p_c {
                background: green;
            }
        </style>
    </ui:define>
    <ui:define name="content">
        <div style="margin:5px;">
            <h:form id="form">
                <p:growl id="msgs" showDetail="false"/>
                <p:panel id="inputItemHieRelap"
                         header="#{esCommonAction.itemTypeListValueOfAlias(itemHieRelapSubcttAction.itemOfEsItemHieRelap .belongToType)}"
                         style="width: 100%">
                    <h:panelGrid columns="2" style="width: 100%">
                        <h:panelGrid id="pgItemHieRelapInput" columns="8" style="width: 100%" >

                            <h:outputLabel for="noItemHieRelap" value="编号:" />
                            <h:inputText id="noItemHieRelap"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.strNo}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[0].disabled_style}"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[0].disabled_flag}">
                                <p:ajax event="blur" update="msgs,pgItemHieRelapBtn"
                                        listener="#{itemHieRelapSubcttAction.blurStrNoToGradeAndOrderidAction}"/>
                            </h:inputText>

                            <h:outputLabel for="name" value="名称:" />
                            <p:selectOneMenu id="name"
                                             value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.name}"
                                             editable="true"
                                             style="#{itemHieRelapSubcttAction.disabledFlags[1].disabled_style}"
                                             disabled="#{itemHieRelapSubcttAction.disabledFlags[1].disabled_flag}">
                                <f:selectItem itemLabel="固定项输入时请选择下列名称" itemValue="" />
                                <f:selectItems value="#{esCommonAction.subcttItemNamelist}" />
                                <p:ajax update="msgs"
                                        listener="#{itemHieRelapSubcttAction.blurStrName}"/>
                            </p:selectOneMenu>
                          <!--  <p:ajax update="msgs,pgItemHieRelapInput"></p:ajax>-->

                            <h:outputLabel for="unitItemInfo" value="单位:"/>
                            <h:inputText id="unitItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.unit}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[2].disabled_style}"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[2].disabled_flag}"/>

                            <h:outputLabel for="contractQuantityItemInfo" value="合同数量:"/>
                            <h:inputText id="contractQuantityItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.contractQuantity}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[3].disabled_style};text-align:right;float:left"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[3].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                                <p:ajax event="blur" update="contractAmountItemInfo"
                                        listener="#{itemHieRelapSubcttAction.blurCalculateAmountAction}"/>
                            </h:inputText>

                            <h:outputLabel for="contractUnitPriceItemInfo" value="综合单价:"/>
                            <h:inputText id="contractUnitPriceItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.contractUnitPrice}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[4].disabled_style};
					                             text-align:right;float:left"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[4].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                                <p:ajax event="blur" update="contractAmountItemInfo"
                                        listener="#{itemHieRelapSubcttAction.blurCalculateAmountAction}"/>
                            </h:inputText>

                            <h:outputLabel for="contractAmountItemInfo" value="合同金额:"/>
                            <h:inputText id="contractAmountItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.contractAmount}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[5].disabled_style};
					                             text-align:right;float:left"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[5].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:inputText>

                            <h:outputLabel for="signPartAPriceItemInfo" value="其中：甲供材单价:"/>
                            <h:inputText id="signPartAPriceItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.signPartAPrice}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[6].disabled_style};
					                                                      text-align:right;float:left"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[6].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:inputText>

                            <h:outputLabel for="note" value="备注内容:" />
                            <h:inputTextarea id="note" 
			                     value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.note}"
                                             rows="1" autoResize="false"
                                             style="#{itemHieRelapSubcttAction.disabledFlags[7].disabled_style};
					                                                     text-align:right;float:left"
                                             disabled="#{itemHieRelapSubcttAction.disabledFlags[7].disabled_flag}"/>

                            <h:outputLabel for="correspondingItemNoItemInfo" value="对应成本计划项号:" />
                            <h:inputText id="correspondingItemNoItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.strCorrespondingItemNo}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[8].disabled_style}"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[8].disabled_flag}">
                                <p:ajax event="blur" update="msgs,correspondingItemNameItemInfo,correspondingPkidItemHieRelap"
                                        listener="#{itemHieRelapSubcttAction.blurCorrespondingPkid}"/>
                            </h:inputText>

                            <h:outputLabel for="correspondingItemNameItemInfo" value="对应成本计划项名:" />
                            <h:inputText id="correspondingItemNameItemInfo"
                                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelap.strCorrespondingItemName}"
                                         style="#{itemHieRelapSubcttAction.disabledFlags[9].disabled_style}"
                                         disabled="#{itemHieRelapSubcttAction.disabledFlags[9].disabled_flag}">
                            </h:inputText>
                        </h:panelGrid>
                        <h:panelGrid id="pgItemHieRelapBtn" columns="1"  style="width:100%">
                            <p:commandButton id="submitBtn" value="#{itemHieRelapSubcttAction.strSubmitBtnName}"
                                             action="#{itemHieRelapSubcttAction.submitThisRecordAction}"
                                             update="pgItemHieRelapBtn,ptt,msgs,pcm,pgItemHieRelapInput">
                            </p:commandButton>
                            <p:commandButton id="resetBtn" value="重置"
                                             action="#{itemHieRelapSubcttAction.reSetAction}"
                                             update="inputItemHieRelap,pcm">
                            </p:commandButton>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:panel>
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloading.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>
                <p:contextMenu for="ptt" id="pcm">
                    <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('upd')}"
                                update="inputItemHieRelap,msgs,ptt">
                    </p:menuitem>
                    <p:menuitem value="删除" icon="ui-icon-close"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('del')}"
                                update="inputItemHieRelap,msgs,ptt">
                    </p:menuitem>
                    <p:menuitem value="复制" icon="ui-icon-copy"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('copy')}"
                                update="inputItemHieRelap,msgs,ptt,pcm">
                    </p:menuitem>
                    <p:menuitem value="剪切" icon="ui-icon-scissors"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('cut')}"
                                update="inputItemHieRelap,msgs,ptt,pcm">
                    </p:menuitem>
                    <p:menuitem value="粘贴（同层_上）" icon="ui-icon-clipboard"
                                rendered="#{itemHieRelapSubcttAction.strPasteBtnRendered}"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('paste_brother_up')}"
                                update="inputItemHieRelap,msgs,ptt,pcm">
                    </p:menuitem>
                    <p:menuitem value="粘贴（同层_下）" icon="ui-icon-clipboard"
                                rendered="#{itemHieRelapSubcttAction.strPasteBtnRendered}"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('paste_brother_down')}"
                                update="inputItemHieRelap,msgs,ptt,pcm">
                    </p:menuitem>
                    <p:menuitem value="粘贴（子层）" icon="ui-icon-clipboard"
                                rendered="#{itemHieRelapSubcttAction.strPasteBtnRendered}"
                                actionListener="#{itemHieRelapSubcttAction.selectRecordAction('paste_children')}"
                                update="inputItemHieRelap,msgs,ptt,pcm">
                    </p:menuitem>
                    <p:menuitem value="成本计划详细内容" icon="ui-icon-search"
                                 onclick ="wvCstplDetail.show()" >
                    </p:menuitem>
                </p:contextMenu>
                <p:dataTable id="ptt" style="width:100%;"
                         value="#{itemHieRelapSubcttAction.itemOfEsItemHieRelapList}"
                         var="record"
                         rowKey="#{record.pkid}"
                         selection="#{itemHieRelapSubcttAction.itemOfEsItemHieRelapSelected}"
                         selectionMode="single"
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                                          {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         paginator="true"
                         paginatorPosition="bottom"
                         rows="20"
                         rowsPerPageTemplate="200,100,50,40,30,20,10"
                         rowIndexVar="row"
                         emptyMessage="数据记录为空..."
                         rowStyleClass="#{record.name eq '合计'? 'c_c': record.name eq '总合计'? 'c_c':null}"
                         scrollable="true"
                         scrollHeight="460">
                    <p:column style="width:30px" headerText="序号">
                        <h:outputText value="#{row + 1}"/>
                    </p:column>

                    <p:column style="width:100px" headerText="成本项号">
                        <h:outputText value="#{record.strCorrespondingItemNo}" escape="false"/>
                    </p:column>
                    <p:column style="width:200px" headerText="成本项名">
                        <h:outputText value="#{record.strCorrespondingItemName}"/>
                    </p:column>

                    <p:column style="width:100px" headerText="分包编号">
                        <h:outputText value="#{record.strNo}" escape="false"/>
                    </p:column>

                    <p:column style="width:200px" headerText="分包名称">
                        <h:outputText value="#{record.name}" />
                    </p:column>

                    <p:column style="width:60px" headerText="分包单位">
                        <h:outputText value="#{record.unit}" style="text-align:right"/>
                    </p:column>

                    <p:column style="width:80px" headerText="分包单价">
                        <h:outputText value="#{record.contractUnitPrice}" style="float: right" >
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:80px" headerText="分包数量">
                        <h:outputText value="#{record.contractQuantity}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:80px" headerText="分包金额">
                        <h:outputText value="#{record.contractAmount}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:100px" headerText="分包甲供材单价">
                        <h:outputText value="#{record.signPartAPrice}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:100px" headerText="分包备注">
                        <h:outputText value="#{record.note}"/>
                    </p:column>

                    <f:facet name="footer">
                         <div style="text-align: left">
                             <p:commandButton id="mngFinishBtn" value="录入结束"
                                              action="#{itemHieRelapSubcttAction.mngFinish_SetInitToStatusFlagAction('2')}"
                                              update=":form:msgs"
                                              rendered="#{itemHieRelapSubcttAction.strIsNullAndInitRendered}"/>
                             <p:commandButton id="mngNotFinishBtn" value="重新录入"
                                              action="#{itemHieRelapSubcttAction.mngNotFinishAction('2')}"
                                              update=":form:msgs"
                                              rendered="#{itemHieRelapSubcttAction.strIsNullAndInitRendered}"/>
                         </div>
                     </f:facet>
                </p:dataTable>
                <p:dialog id="dLCstplDetail" widgetVar="wvCstplDetail"  header="成本计划">
                    <p:dataTable id="pdtCstpl"
                                   value="#{(itemHieRelapSubcttAction.itemOfEsItemHieRelapList_Cstpl)}"
                                   var="recordCstpl"
                                   dynamic="true"
                                   selectionMode="single"
                                   rowKey="#{recordCstpl.pkid}"
                                   selection="#{itemHieRelapSubcttAction.itemOfEsItemHieRelapSelected_Cstpl}"
                                   paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink}
                                                 {LastPageLink} {RowsPerPageDropdown}"
                                   paginator="true"
                                   paginatorPosition="bottom"
                                   rows="15"
                                   rowsPerPageTemplate="100,50,30,15,5"
                                   emptyMessage="数据记录为空..."
                                   scrollable="true"
                                   scrollHeight="400">

                        <!--selectionMode="multiple"可多选，但是没有多选的CheckBox-->
                        <!--<p:ajax event="rowSelect" listener="#{itemHieRelapSubcttAction.onRowSelect_Cstpl}"
                                update=":form:ptt" oncomplete="wvCstplDetail.hide()"/>-->

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('strNo').comments}">
                            <h:outputText value="#{recordCstpl.strNo}" escape="false"/>
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('name').comments}">
                            <h:outputText value="#{recordCstpl.name}" />
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('unit').comments}">
                            <h:outputText value="#{recordCstpl.unit}" style="text-align:right"/>
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('UnitPrice').comments}">
                            <h:outputText value="#{recordCstpl.contractUnitPrice}" style="float: right" >
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:outputText>
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('contractQuantity').comments}">
                            <h:outputText value="#{recordCstpl.contractQuantity}" style="float: right">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:outputText>
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('contractAmount').comments}">
                            <h:outputText value="#{recordCstpl.contractAmount}" style="float: right">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:outputText>
                        </p:column>

                        <p:column headerText="#{itemHieRelapSubcttAction .columnModelSelectedMap.get('note').comments}">
                            <h:outputText value="#{recordCstpl.note}" />
                        </p:column>

                        <f:facet name="footer">
                            <p:commandButton id="cstplSelSubmitBtn" value="提交"
                                 action="#{itemHieRelapSubcttAction.submitAction_Cstpl()}"
                                 update=":form:ptt" oncomplete="wvCstplDetail.hide()"/>
                        </f:facet>
                    </p:dataTable>
                </p:dialog>
            </h:form>
        </div>
    </ui:define>
</ui:composition>